#!/usr/bin/perl
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2004 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

$line = 0;

while (<STDIN>)
{
	$line++;

	($time, $thread, $trace_id, $junk) = split " ", $_, 4;

#printf("time(%s) thread(%s) trace_id(%s) junk(%s)\n", $time, $thread, $trace_id, $junk);

	if ($trace_id eq "_SRA")
	{
		if (index($junk, "The System Registry") > -1)
		{
			while (<STDIN>)
			{
				$line++;
				($a, $b, $error_code) = split " ", $_, 3;
				chomp $error_code;
				last;
			}

			while (<STDIN>)
			{
				$line++;
				($a, $b, $error_message) = split " ", $_, 3;
				$error_message =~ s/^\s*(.*?)\s*$/$1/;
				$error_message =~ s/"//g;
				last;
			}

			while (<STDIN>)
			{
				$line++;
				last;
			}

			while (<STDIN>)
			{
				$line++;
				($a, $b, $file_name) = split " ", $_, 3;
				chomp $file_name;
				$file_name =~ s/"//g;
				last;
			}

			while (<STDIN>)
			{
				$line++;
				($a, $b, $file_version) = split " ", $_, 3;
				chomp $file_version;
				$file_version =~ s/"//g;
				last;
			}

			while (<STDIN>)
			{
				$line++;
				($a, $b, $line_number) = split " ", $_, 3;
				chomp $line_number;
				last;
			}

			printf("%u: %s %s %s %s:%s:%s %s\n", $line, $time, $thread, $error_code, $file_name, $line_number, $file_version, $error_message);
		}
		else
		{
			printf("%u: %s %s %s", $line, $time, $thread, $junk);
		}
	}
}
